package com.sufen.gb.controller;

import com.sufen.common.reponse.CodeMsg;
import com.sufen.common.reponse.ResultMessage;
import com.sufen.common.request.BaseController;
import com.sufen.common.request.RequestParms;
import com.sufen.gb.entity.Dict;
import com.sufen.gb.service.DictService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 数据字典 前端控制器
 * </p>
 *
 * @author mybatis-plus
 * @since 2021-11-30
 */

@Controller
@RequestMapping("/dict")
public class DictController extends BaseController {
    private static final Logger logger = LoggerFactory.getLogger(DictController.class);
    @Autowired
    DictService dictService;

    @RequestMapping("/getDictById")
    @ResponseBody
    public void getDictById(@RequestBody RequestParms requestParms, HttpServletResponse response){


//        logger.info("根据id查询字典详细信息："+requestParms);
        //对参数进行校验
//        if (StringUtils.isEmpty(requestParms.getConditions().get("id"))){
//            logger.warn("查询ID为空，不能进行查询");
//            renderErrorJson(response,ResultMessage.error((long) CodeMsg.ID_EMPTY.getCode(),
//                    CodeMsg.ID_EMPTY.getMsg()));return;
//        }
//        Dict dict = dictService.getDictById((Integer) requestParms.getConditions().get("id"));
//        logger.info("Result:"+dict!=null?dict.toString():"查询数据为空！");
        //renderJson(response, ResultMessage.data(dict));
        renderJson(response,ResultMessage.success("更新成功"));
    }

}

